<template>
  <div>
      用户名<input type="text" v-model="username" @blur="uui">{{error_name}}<br>
      密码<input type="text" v-model="password"><br>
      邮箱<input type="text" v-model="email"><br>
      验证码<input type="text" v-model="code"><img src="http://127.0.0.1:8000/image_code"><br>
      <input type="button" value="注册" @click="reg">
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            username:"",
            password:"",
            email:"",
            code:"",
            error_name:'',
        }
    },methods:{
    uui(){
            const re = /^\w{4,8}$/
            if(re.test(this.username)){
            this.error_name = '√'
            }else{
            this.error_name = '请输入4-8个字节符'
            }
        },
    reg(){
        const data={
            'username':this.username,
            'password':this.password,
            'email':this.email,
        }
        this.axios.post('/zhengce1/',data).then(resp=>{
            console.log(resp.data)
        }).catch(error=>{
            console.log(error.respons)
        })
    }
        }
}
</script>

<style>

</style>